Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BindDefaultValue #10

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

BindDefaultValue #10

wants to merge 7 commits into from

Conversation

rs-frank
Copy link

type Info struct {
Ext string d:"aaa"
Name string d:"123"
}
type ShowInfo struct {
Name string d:"name"
Info
CreateTime time.Time d:"2020-01-02 03:04:01"
}

func TestBindDefaultValue(t *testing.T) {
var s ShowInfo
BindDefaultValue(&s)
log.Printf("%+v", s)
}

@mrwormhole
Copy link
Contributor

Hello @rs-frank, can you add more test cases for other default value types like bool, int, float?

@rs-frank
Copy link
Author

Hello @rs-frank, can you add more test cases for other default value types like bool, int, float?

func (s InfoForDefaultValueFunc) Default() reflect.Value {
return reflect.ValueOf(InfoForDefaultValueFunc{Name: "test name"})
}
type InfoForDefaultValueFunc struct {
Ext string d:"aaa"
Name string d:"123"
}
type Info struct {
Ext string d:"aaa"
Name string d:"123"
BoolFalse string d:"false"
BoolTrue string d:"true"
Float float32 d:"12.21"
Float64 float64 d:"12.51"
Number int d:"12"
}
type ShowInfo struct {
Name string d:"name"
Info
InfoForDefaultValueFunc InfoForDefaultValueFunc
CreateTime time.Time d:"2020-01-02 03:04:01"
}

func TestBindDefaultValue(t *testing.T) {
var s ShowInfo
BindDefaultValue(&s)
data, _ := json.Marshal(s)
log.Printf("%s", data)
}

@shyandsy
Copy link
Collaborator

shyandsy commented Apr 16, 2022

could you merge your commit, and rebase your code onto the develop branch?
and I will review it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants